﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Collections.Specialized;
using System.Configuration;

namespace OAuth.Sohu
{
    public class SohuOAuthConfig:IOAuthConfig
    {
        private NameValueCollection SohuSection = (NameValueCollection)ConfigurationManager.GetSection("SohuSectionGroup/SohuSection");

        /// <summary>
        /// 得到Sohu的AppKey
        /// </summary>
        /// <returns></returns>
        public string GetAppKey()
        {
            return SohuSection["Appkey"];
        }

        /// <summary>
        /// 得到Sohu的AppSecret
        /// </summary>
        /// <returns></returns>
        public string GetAppSecret()
        {
            return SohuSection["AppSecret"];
        }

        /// <summary>
        /// 得到回调地址
        /// </summary>
        /// <returns></returns>
        public Uri GetCallBackURI()
        {
            return new Uri(SohuSection["CallBackURI"]);
        }

        /// <summary>
        /// 得到请求类型
        /// </summary>
        /// <returns></returns>
        public OAuthEnum.RequestType GetRequestType()
        {
            string TypeString = SohuSection["RequestType"];
            OAuthEnum.RequestType Type = new OAuthEnum.RequestType();
            switch (TypeString.ToUpper())
            {
                case "GET": Type = OAuthEnum.RequestType.GET; break;
                case "POST": Type = OAuthEnum.RequestType.POST; break;
                case "HEADER": Type = OAuthEnum.RequestType.HEADER; break;
                default: Type = OAuthEnum.RequestType.GET; break;
            }
            return Type;
        }
    }
}
